﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		teacherId = sessionAdvice.getAutherUserID();
		
		/* 当前在校生判断 grade + schooling_length > ? */
		gradeLeast = year( now() );
		if ( month( now() ) < 9 ) {
			gradeLeast = year( now() ) - 1;
		}
		sql = "SELECT 
					a.grade, count(a.cls_id) cls_id, 
					sum(a.cls_size) cls_size, sum(a.cls_scale) cls_scale 
				FROM t_class a 
					INNER JOIN t_subject b ON b.sbj_id = a.sbj_id 
				WHERE  
					a.teacher_in_charge = :teacherId 
					AND 
					(a.grade + b.schooling_length) > :yearNow 
				GROUP BY a.grade 
				ORDER BY a.grade DESC";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="yearNow", value=gradeLeast, cfsqltype="cf_sql_integer" );
		
		rs_grade = queryObj.execute( sql=sql ).getResult();
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		event.setArg("pageTitle", "教学运行基础数据 - 学生学籍 ");
		
		currentTab = event.getArg("TabID", "labFormClass");
		
		if ( rs_grade.recordCount and currentTab eq "labFormClass" ) {
			currentTab = "labGrade" & rs_grade["grade"][1];
		}
		
		if ( len(event.getArg('Grade')) ) {
			currentTab = "labGrade" & event.getArg('Grade');
		}
		
		targetArgs = structNew();
		
		passArgs = structNew();
		/* 搜索学生档案 */
		keyword = event.getArg("Keywords");
	 
		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			 
			sql = "SELECT 
						  c.stu_id, c.stu_name, 
						  c.nationality, d.student_prop 
					FROM t_class a 
						INNER JOIN i_stu_class_info b ON b.cls_id = a.cls_id 
						INNER JOIN t_student c ON c.stu_id = b.stu_id 
						 INNER JOIN t_student_status d ON d.stu_id = c.stu_id  
					WHERE 
						a.TEACHER_IN_CHARGE = :teacherId 
						AND 
						(
							c.stu_id LIKE :condition 
							OR 
							c.stu_name LIKE :condition 
						)
					ORDER BY c.stu_name ";
					
			queryObj = new Query( datasource=application.dnsSlave,maxRows=60  ) ;
			
			queryObj.addParam( name="teacherId", value=teacherId , cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
						
			rs_student = queryObj.execute( sql=sql ).getResult();
		}
		
		structInsert(passArgs, 'TchID', teacherId, true);
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">教学活动</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>当前管理的班级
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables"> 
                        <cfloop query="rs_grade" >
							<span <cfif currentTab eq "labGrade" & rs_grade.grade>class="active"</cfif> id="labGrade<cfoutput>#rs_grade.grade#</cfoutput>" tabTarget="Grade<cfoutput>#rs_grade.grade#</cfoutput>"><cfoutput>#rs_grade.grade#</cfoutput></span>
						</cfloop>
                              <span <cfif currentTab eq "labImport">class="active"</cfif> id="labImport" tabTarget="Import">导入学生数据</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				 
				<cfloop query="rs_grade" >
					<cfset structInsert(passArgs, "Grade", rs_grade.grade, true) />
					
					<div id="Grade<cfoutput>#rs_grade.grade#</cfoutput>" class="tabContent">
						<div class="noticeBlock">
							<div class="operation">
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('studentByHeadTeacherGradeDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载<cfoutput>#grade#</cfoutput>级学生名单</span></a>
							</div>
							<h3><cfoutput>#rs_grade.grade#</cfoutput>级</h3>
							<p><span class="img icon16x16 message"></span>共计<em><cfoutput>#rs_grade.cls_id#</cfoutput></em>个行政班, 计划招生规模<em><cfoutput>#rs_grade.cls_size#</cfoutput></em>人, 实际学生人数<em><cfoutput>#rs_grade.cls_scale#</cfoutput></em>.</p>
							<hr/>
						</div>
					 
						<cfset sql = "SELECT 
											a.cls_id, a.cls_name, 
											a.cls_size, a.cls_scale, 
											t_campus.campus_name, 
											t_subject.sbj_name  
										FROM t_class a 
											 INNER JOIN t_campus ON t_campus.campus_id = a.campus_id  
											 INNER JOIN t_subject ON t_subject.sbj_id = a.sbj_id 
										WHERE 
											 a.teacher_in_charge = :teacherId
									 		 and 
									 		 a.grade = :grade 
										ORDER BY a.cls_name "/>
                                        
						<cfset queryObj = new Query( datasource=application.dnsSlave )/>
                        <cfset queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" )/>
                        <cfset queryObj.addParam( name="grade", value=rs_grade.grade, cfsqltype="cf_sql_char" )/>
                        
                        <cfset rs_class= queryObj.execute( sql=sql ).getResult()/>
                        
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td>班级</td>
									<td>所在专业</td>
									<td width="80">所在校区</td>
									<td width="60" align="center">计划人数</td>
									<td width="40" align="center">学生数</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody> 
                                <cfloop query="rs_class" >
									<cfset structInsert(targetArgs, "Class", rs_class.cls_id, true) />
									<cfset row++ />
									<tr class="editRows <cfif rs_class.cls_size lt rs_class.cls_scale>noticeRow1</cfif>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_class.cls_name#</cfoutput></td>
										<td><cfoutput>#rs_class.sbj_name#</cfoutput></td>
										<td><cfoutput>#rs_class.campus_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_class.cls_size#</cfoutput></span></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_class.cls_scale#</cfoutput></span></td>
										<td><a class="stat info" href="<cfoutput>#buildURL('studentByClass', targetArgs)#</cfoutput>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</div>
				</cfloop>
                    
                    <div id="Import" class="tabContent">
					
					<div class="noticeBlock">
                         <br/>
						<h3>导入学生学籍数据</h3>
						<p><span class="img icon16x16 message"></span>请严格按照如下的数据模板在电子表格文件中录入学生基础数据. 点击<a href="<cfoutput>#buildURL('importStudentTemplate')#</cfoutput>">下载学生基础信息录入模板</a>, 在录入信息时请勿更改第一行表头内容.</p>
						
                              <p><span class="img icon16x16 link"></span>必填信息（<font color="#FF0000">注意：学号一旦导入不能修改，务必确认学号正确</font>）</p>
						<table>
							<tr>								
								<td>学号</td><td>护照名</td><td>性别</td><td>护照号</td><td>国籍</td>
							</tr>
							<tr>
								<td>自行编定</td><td>护照名</td><td>男/女</td><td>护照号</td><td>国家名字</td>
							</tr>
                                   
						</table>
                             （ <b>作为班主任导入的学生，默认都为普通进修生， 学生类型修改请联系行政人员</b> ）
						<br/><br/>
						<p><span class="img icon16x16 link"></span>选填信息（<font color="#FF0000">注意：入学时间会参与学生成绩打印业务，最好填上</font>）</p>
						<table>
							<tr>
                                   	<td>中文名</td>
								<td>出生日期</td>
								<td>入学日期</td>
                                        <td>护照有效期</td>
                                        <td>婚姻状况</td>
								<td>家庭住址</td>
                                        <td>在华住址</td>
                                       	<td>邮件</td>
                                       	<td>电话</td>
                                        <td>经费来源</td>
							</tr>
							<tr>
                                   	<td>中文名字</td>
								<td>YYYYMMDD</td>
								<td>YYYYMMDD</td>
                                        <td>YYYYMMDD</td>
                                        <td>已婚/未婚</td>
								<td>家庭通讯地址</td>
                                        <td>在华住址</td>
                                        <td>邮件</td>
                                        <td>电话</td>
                                        <td>经费来源名称</td>
							</tr>
						</table>
						<hr/>
					</div>
					
					<form target="output" onSubmit="javascript:return processVerfiyForm('formImport');" id="formImport" class="formWrapper" method="post" enctype="multipart/form-data" action="<cfoutput>#buildURL('importStudentDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>导入数据文件</b>
							<input name="upload" id="upload" type="file" verification="required" />
						</div>
						
						<div class="lable"><input id="importTrigger" class="button" type="submit" value="导入学籍数据" /></div>
					</form>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
							$("#importTrigger").click(function(){
								$("#output").attr("src","about:blank").removeClass("hidden_elem");
							});
						});
						// -->
						//]]>
					</script>
					
					
					<iframe name="output" id="output" class="UIframeBox hidden_elem" src="about:blank" frameborder="0"></iframe>
					
				</div>
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentByHeadTeacher')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						<input type="hidden" name="TeacherID" value="<cfoutput>#teacherId#</cfoutput>" />
						
						<div class="label">
							<b>学号或姓名</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>
                         	
						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_student" >
									
									<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<dl <cfif not propertyAdvice.getInSchool()>class="disabled"</cfif>>
										<dt>
											<a href="<cfoutput>#buildURL('studentProfileView', passArgs)#</cfoutput>">
												<em class="people"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_student.stu_name#</cfoutput> (<cfoutput>#rs_student.nationality#</cfoutput>)</h3>
													<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>					
							</div>
						</div>
					
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>

